#!/usr/bin/env python
#  -*- coding: utf-8 -*-
__author__ = 'yinq'

import time


def timer(func):
    def deco(*args, **kwargs):
        start_time = time.time()
        func(*args, **kwargs)  # run t1
        stop_time = time.time()
        print("the func run time is %s" % (stop_time - start_time))

    return deco


# def timer():
#     def deco():
#         pass
#
@timer  # t1 = timer(t1)
def t1():
    time.sleep(1)
    print("in the t1")


@timer  # t2=timer(t2)  = deco   t2()=deco()
def t2(name, age):
    print("t2:", name, age)


print(timer(t1))
# t1 = timer(t1)  # 把timer的内存地址给t1
t1()  # run deco
t2("derek", 22)
